// AnsiAttribute.cpp: implementation of the CAnsiAttribute class.
//
//////////////////////////////////////////////////////////////////////

#include "stdafx.h"
#include "AnsiTerminal.h"
#include "AnsiAttribute.h"

#ifdef _DEBUG
#undef THIS_FILE
static char THIS_FILE[]=__FILE__;
#define new DEBUG_NEW
#endif

COLORREF ANSI_COLOR_TO_RGB[16] = { 0x000000, 0x000080, 0x008000, 0x008080, 0x800000, 0x800080, 0x808000, 0xC0C0C0, 
								   0x808080, 0x0000FF, 0x00FF00, 0x00FFFF, 0xFF0000, 0xFF00FF, 0xFFFF00, 0xFFFFFF};

//////////////////////////////////////////////////////////////////////
// Construction/Destruction
//////////////////////////////////////////////////////////////////////

CAnsiAttribute::CAnsiAttribute()
{
	Reset();
}

void CAnsiAttribute::Reset()
{
	bHighLight	= FALSE; //opt
	bBlink		= FALSE;
	bUnderLine	= FALSE;
	bInverse	= FALSE;
	
	nForeColor	= COLOR_GRAY;
	nBackColor	= COLOR_BLACK;

	nFontIndex = FONT_SONG;
}

COLORREF CAnsiAttribute::GetRgbForeColor()
{
	return ANSI_COLOR_TO_RGB[bInverse? nBackColor: nForeColor + bHighLight * 8];
}

COLORREF CAnsiAttribute::GetRgbBackColor()
{
	return ANSI_COLOR_TO_RGB[bInverse? nForeColor: nBackColor];
}
